package com.example.example_mvp;

public class PresenterImpl implements ILoginContract.ILoginPresenter,ICallback {
    private ILoginContract.ILoginView mLoginView;
    private ILoginContract.ILoginModel mLoginModel;
    public PresenterImpl(ILoginContract.ILoginView iLoginView){
        this.mLoginModel=new LoginModelImpl();
        this.mLoginView=iLoginView;
    }
    @Override
    public void login(String name, String password) {
        this.mLoginModel.login(name,password,this);
    }

    @Override
    public void receive(String success) {
        if(VailString.IsEmpty.equals(success)){
            this.mLoginView.showToast("用户名或密码不能为空");
        }else if(VailString.IsTrue.equals(success)){
            this.mLoginView.navigateToMain();
        }else if(VailString.IsWrong.equals(success)){
            this.mLoginView.showToast("用户名或密码错误");
        }else {
            this.mLoginView.showToast("登陆失败");
        }
    }
}
